package com.example.myapplication.DesignPatterns.factory;

import com.example.myapplication.thirdcamera.util.Log;

/**
 * 客户端
 */
public class FactoryClient {

    public static void main(String[] args) throws Exception {
        //使用反射机制实例化工厂对象，因为字符串是可以通过变量改变的
        String pageName = "com.example.myapplication.DesignPatterns.factory";
        Factory addFactory = (Factory) Class.forName(pageName+".AddFactory").newInstance();
        Factory subFactory = (Factory) Class.forName(pageName+".SubFactory").newInstance();
        Factory mulFactory = (Factory) Class.forName(pageName+".MulFactory").newInstance();
        Factory divFactory = (Factory) Class.forName(pageName+".DivFactory").newInstance();

        //根据工厂对象创建对应的实例
        Log.i("dove","factory_client-"+addFactory.createOperate());
        Log.i("dove","factory_client-"+subFactory.createOperate());
        Log.i("dove","factory_client-"+mulFactory.createOperate());
        Log.i("dove","factory_client-"+divFactory.createOperate());
    }
}

